package view.GUI;

import controller.DrawDialog;
import controller.Serializer;
import controller.StdDraw;
import controller.commands.ExecuteThread;
import core.ConnectException;
import core.TriggerPort;
import model.codebehind.CodeModel;

/**
 *
 * @author Ben
 */
public class Main {

    public static void main(String args[]) {
        if(args.length == 0){
            System.out.println(LabelReader.getInstance().getString("UsageCommand"));
        }else{
            CodeModel cmodel = new CodeModel();
            Serializer ser = new Serializer(cmodel, args[0]);
            TriggerPort trigger = ser.deserialize();

            DrawDialog dialog = new DrawDialog();
            StdDraw.getInstance().setPanel(dialog.getPanel());
            StdDraw.getInstance().getTurtle().reset();
            System.out.println(LabelReader.getInstance().getString("RunningProgram"));
            try {
                ExecuteThread et = new ExecuteThread( trigger);
                et.start();
            } catch (ConnectException ex) {
                System.out.println("ExcecuteCommand: " + ex.getMessage());
            }
            System.out.println(LabelReader.getInstance().getString("YourProgramIsNowBeeingExecuted"));
        }
    }
}
